<?php

class Avatar_Form_Admin_Level extends Engine_Form {
	
	public function init() {
		$this->setTitle ( 'Member Level Settings' )->setDescription ( 'These settings are applied on a per member level basis. Start by selecting the member level you want to modify, then adjust the settings for that level below.' )->setAttrib ( 'name', 'level_settings' );
		
		$this->loadDefaultDecorators ();
		$this->getDecorator ( 'Description' )->setOptions ( array ('tag' => 'h4', 'placement' => 'PREPEND' ) );
		
		// prepare user levels
		$table = Engine_Api::_ ()->getDbtable ( 'levels', 'authorization' );
		$select = $table->select ();
		$user_levels = $table->fetchAll ( $select );
		$public_level = $table->getPublicLevel ();
		foreach ( $user_levels as $user_level ) {
			if ($public_level->level_id != $user_level->level_id)
				$levels_prepared [$user_level->level_id] = $user_level->getTitle ();
		}
		
		// category field
		$this->addElement ( 'Select', 'level_id', array ('label' => 'Member Level', 'multiOptions' => $levels_prepared, 'onchange' => "javascript:window.location.href = en4.core.baseUrl + 'admin/avatar/level/'+this.value;", 'ignore' => true ) );
		
		$this->addElement ( 'Radio', 'web_cam', array ('label' => 'Allow WebCam Snapshot?', 'description' => 'Do you want to allow this user level to take photos with webcam and set them as avatars?', 'multiOptions' => array (1 => 'Yes, allow for this user level.', 0 => 'No, deny for this user level.' ), 'value' => 1 ) );
		
		$this->addElement ( 'Radio', 'avatarcollection', array ('label' => 'Allow Avatar Collections?', 'description' => 'Do you want to allow this user level to choose avatar from avatar collections?', 'multiOptions' => array (1 => 'Yes, allow for this user level.', 0 => 'No, deny for this user level.' ), 'value' => 1 ) );
		
		$this->addElement ( 'Button', 'submit', array ('label' => 'Save Settings', 'type' => 'submit', 'ignore' => true ) );
	
	}
}
